#ifndef REPAIRWIDGET_H
#define REPAIRWIDGET_H

#include <QWidget>
#include<QSqlTableModel>
#include"src/mes.h"

namespace Ui {
class RepairWidget;
}

class RepairWidget : public QWidget
{
    Q_OBJECT

public:
    explicit RepairWidget(QWidget *parent = nullptr);
    ~RepairWidget();

private slots:
    void on_pushButton_clicked();

    void on_pushButton_3_clicked();

    void on_exportButton_clicked();

    void slot_copyData();

    void slotContextMenu(QPoint);

    void on_refreshButton_clicked();

    void on_workNumber_textEdited(const QString &arg1);

private:
    Ui::RepairWidget *ui;
    void initTableView(QStringList sqlist);

    QMenu *popMenu;
    int selectCurrentRow;
    int selectCurrentColumn;
};


class RepairTable:public QSqlTableModel
{
    Q_OBJECT
public:
    RepairTable( QObject * parent = 0, QSqlDatabase db = Mes::getInstance()->db );

    bool setData( const QModelIndex &index, const QVariant &value, int role) override;
    QVariant data(const QModelIndex &index, int role) const override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;

    void setSqlist(QStringList sqlist){this->sqlist=sqlist;};

    QMap<int, Qt::CheckState> check_state_map;

private:
    int checkColumn = 0;
//    QList<int> checkStateList;

    QStringList sqlist;

protected:
    QString selectStatement() const override;

};
#endif // REPAIRWIDGET_H
